package ModelLayer;
import java.util.ArrayList;

public class DvdCollection
{
  private ArrayList<DVD>dvdCollection;
  private static DvdCollection instance = null;
  public static DvdCollection getInstance() {
       if (instance == null) {
            instance = new DvdCollection();
       }
        return instance;
    }
  private DvdCollection()
  {
      dvdCollection = new ArrayList<DVD>();
    }
     public void addDvd(DVD newDvd)
    {
        dvdCollection.add(newDvd);
    }
    public void deleteDvd(DVD delDvd)
    {
        dvdCollection.remove(delDvd);
    }
    public DVD findDvd(String title)
    {
        int i = 0;
        DVD result = null;
        boolean found = false;
        while (i<dvdCollection.size() && !found)
        {
            if(dvdCollection.get(i).getDvdTitle().equals(title))
            {
                result = dvdCollection.get(i);
                found = true;
            }
            i++;
        }
        return result;
    }
    public ArrayList<DVD>getAll()
    {
        return dvdCollection;
    }
}

